home *** CD-ROM | disk | FTP | other *** search
- 'Module1 (Code)
- Option Explicit
- Public ChoixNumΘros(5), NumΘros(49), RΘsultats(6)
- Public i, j, NbreGrilles, Nb, k, Li, Col As Byte
- Dim cell As Range
-
- '************ feuille bulletin ***********
- 'Clic sur le bouton Jouer dans la feuille bulletin
- Sub Jouer()
- Load FrmJouer
- FrmJouer.Opt2 = True
- FrmJouer.Show
- End Sub
-
- 'Fonction personnalisΘe utilisΘe dans les cellules C6, 06,
- Function NbSelections(Plage)
- Nb = 0
- For Each cell In Plage
- If cell.Interior.ColorIndex = 3 Or cell.Interior.ColorIndex = 4 Then
- Nb = Nb + 1
- End If
- Next
- NbSelections = Nb
- End Function
-
- Function Calculer()
- Range("C24:C25,O24:O25,AA24:AA25,AM24:AM25,AY24:AY25,BK24:BK25,BW24:BW25,CI24:CI25").Calculate
- End Function
-
- 'Routine de tirage au hasard des 6 numΘros appelΘe par la procΘdure
- 'exΘcutΘe lors du clic sur le bouton OK du formulaire FrmJouer
- Sub Choix()
- For i = 1 To 49
- NumΘros(i) = False
- Next
- For i = 0 To 5
- ChoixNumΘros(i) = Int(Rnd * 49) + 1
- If Not NumΘros(ChoixNumΘros(i)) Then
- NumΘros(ChoixNumΘros(i)) = True
- Else
- i = i - 1
- End If
- Next
- End Sub
-
- 'Clic sur le bouton Effacer dans la feuille bulletin
- Sub EffacerGrilles()
- Dim strRange As String
- If NbreGrilles = Empty Or NbreGrilles = 0 Then
- i = 0
- For k = 1 To 8
- If Range("Grille" & k).Interior.ColorIndex = 15 Then
- Range("Grille" & k).Interior.ColorIndex = 2
- i = i + 1
- End If
- Next k
- NbreGrilles = i
- End If
- Select Case NbreGrilles
- Case 1 To 2
- strRange = "C3:W21"
- Case 3 To 4
- strRange = "C3:AU21"
- Case 5 To 6
- strRange = "C3:BS21"
- Case 7 To 8
- strRange = "C3:CQ21"
- Case Else
- strRange = "C3:CQ21"
- End Select
- For Each cell In Range(strRange)
- If cell.Font.ColorIndex = 2 Or cell.Font.ColorIndex = 5 Or cell.Font.ColorIndex = 6 Then
- cell.Font.ColorIndex = 3
- cell.Interior.ColorIndex = 2
- End If
- Next
- Calculer
- End Sub
-
- '************ feuille tirage ***********
- 'Clic sur le bouton Effacer
- Sub EffacerRΘsultats()
- For Each cell In Range("A1:M24")
- If cell.Font.ColorIndex = 2 Then
- cell.Font.ColorIndex = 3
- cell.Interior.ColorIndex = 2
- End If
- Next
- Calculer
- End Sub
-
- 'Clic sur le bouton Contr⌠ler
- Sub Controle()
- Dim Gagnants As Byte
- i = 0
- 'Chaque cellule de la grille du tirage est examinΘe
- For Each cell In Range("C4:K22")
- 'L'un des 6 premiers numΘros tirΘs
- If cell.Interior.ColorIndex = 3 Then
- RΘsultats(i) = cell.Value
- i = i + 1
- End If
- 'Le numΘro complΘmentaire
- If cell.Interior.ColorIndex = 4 Then
- RΘsultats(6) = cell.Value
- End If
- Next
- 'SΘlection de la feuille bulletin
- Sheets("bulletin").Select
- 'la boucle qui examine chaque grille
- For i = 1 To 8
- Gagnants = 0
- Range("Grille" & i).Select
- 'Recherche des 6 premiers numΘros dans la grille
- For j = 0 To 5
- Li = (RΘsultats(j) Mod 10) * 2
- Col = (Int(RΘsultats(j) / 10)) * 2
- If ActiveCell.Offset(Li, Col).Font.ColorIndex = 2 Then
- ActiveCell.Offset(Li, Col).Font.ColorIndex = 5
- Gagnants = Gagnants + 1
- End If
- Next j
- 'S'il y a 5 numΘros gagnants, recherche du numΘro complΘmentaire
- If Gagnants = 5 Then
- Li = (RΘsultats(6) Mod 10) * 2
- Col = (Int(RΘsultats(6) / 10)) * 2
- If ActiveCell.Offset(Li, Col).Font.ColorIndex = 2 Then
- ActiveCell.Offset(Li, Col).Font.ColorIndex = 6
- Gagnants = Gagnants + 1
- End If
- End If
- Next i
- Range("A1").Select
- End Sub
-
- '*************************************************************************************
- 'Feuille1 (Code)
- Option Explicit
-
- Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
- Dim Colonne, NbreNumΘros As Byte
- Cancel = True
- Colonne = Target.Column
- Select Case Colonne
- Case 3 To 11
- NbreNumΘros = Range("Nbre1").Value
- k = 1
- Case 15 To 23
- NbreNumΘros = Range("Nbre2").Value
- k = 2
- Case 27 To 35
- NbreNumΘros = Range("Nbre3").Value
- k = 3
- Case 39 To 47
- NbreNumΘros = Range("Nbre4").Value
- k = 4
- Case 51 To 59
- NbreNumΘros = Range("Nbre5").Value
- k = 5
- Case 63 To 71
- NbreNumΘros = Range("Nbre6").Value
- k = 6
- Case 75 To 83
- NbreNumΘros = Range("Nbre7").Value
- k = 7
- Case 87 To 95
- NbreNumΘros = Range("Nbre8").Value
- k = 8
- End Select
- On Error Resume Next
- If Val(Target.Value) >= 1 And Target.Font.Size < 18 Then
- If Target.Font.ColorIndex = 2 Then
- Target.Font.ColorIndex = 3
- Target.Interior.ColorIndex = 2
- Else
- If NbreNumΘros = 6 Then
- MsgBox "Cette grille est dΘjα complΦte"
- Exit Sub
- End If
- Target.Font.ColorIndex = 2
- Target.Interior.ColorIndex = 3
- End If
- End If
- Calculer
- If Range("Nbre" & k).Value >= 1 And Range("Grille" & k).Interior.ColorIndex = 2 Then
- Range("Grille" & k).Interior.ColorIndex = 15
- ElseIf Range("Nbre" & k).Value = 0 And Range("Grille" & k).Interior.ColorIndex = 15 Then
- Range("Grille" & k).Interior.ColorIndex = 2
- End If
- End Sub
-
- Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
- If ActiveCell.Address = Range("A1").Address Then
- Range("D27").Select
- Else: Exit Sub
- End If
- End Sub
-
- Private Sub Worksheet_Activate()
- Range("D27").Select
- End Sub
-
-
- '*************************************************************************************
- 'Feuille2 (Code)
- Option Explicit
-
- Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
- Dim NbreNumΘros As Byte
- Cancel = True
- NbreNumΘros = Range("Nbre").Value
- On Error Resume Next
- If Val(Target.Value) >= 1 And Target.Font.Size < 18 Then
- If Target.Font.ColorIndex = 2 Then
- Target.Font.ColorIndex = 3
- Target.Interior.ColorIndex = 2
- Else
- If NbreNumΘros = 7 Then
- MsgBox "Cette grille est dΘjα complΦte"
- Exit Sub
- End If
- If NbreNumΘros < 6 Then
- Target.Font.ColorIndex = 2
- Target.Interior.ColorIndex = 3
- Else
- Target.Font.ColorIndex = 2
- Target.Interior.ColorIndex = 4
- End If
- End If
- End If
- Calculer
- End Sub
-
- Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
- If ActiveCell.Address = Range("A1").Address Then
- Range("O3").Select
- Else: Exit Sub
- End If
- End Sub
-
- Private Sub Worksheet_Activate()
- Range("O3").Select
- End Sub
-
- '*************************************************************************************
- 'FrmJouer (code)
- Option Explicit
-
- 'Clic sur le bouton Annuler
- Private Sub CmdAnnuler_Click()
- Unload FrmJouer
- End Sub
-
- 'Clic sur le bouton OK
- Private Sub CmdOK_Click()
- If FrmJouer.Opt2 Then
- NbreGrilles = 2
- ElseIf FrmJouer.Opt4 Then
- NbreGrilles = 4
- ElseIf FrmJouer.Opt6 Then
- NbreGrilles = 6
- ElseIf FrmJouer.Opt8 Then
- NbreGrilles = 8
- End If
- Unload FrmJouer
- EffacerGrilles
- For k = 1 To NbreGrilles
- Choix
- Range("Grille" & k).Select
- Range("Grille" & k).Interior.ColorIndex = 15
- For j = 0 To 5
- Li = (ChoixNumΘros(j) Mod 10) * 2
- Col = (Int(ChoixNumΘros(j) / 10)) * 2
- ActiveCell.Offset(Li, Col).Font.ColorIndex = 2
- ActiveCell.Offset(Li, Col).Interior.ColorIndex = 3
- Next j
- Next k
- Calculer
- Range("A1").Select
- NbreGrilles = 0
- End Sub
-